package scrum.gui.Employee;
import java.util.ArrayList;
import javax.swing.*;
import scrum.entity.Employee;





public class EmployeePane extends javax.swing.JPanel {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
  
    private boolean             bEditable;
    
    ArrayList<Employee> employeList;
   
    
    /** Creates new form ConstantPoolPropPane */
    public EmployeePane() {
        initComponents();
    }
    
    public void setModifyMode(boolean bEditableIn) {
        bEditable = bEditableIn;
        btnAddNew.setEnabled(bEditable);
        btnModify.setEnabled(bEditable);
        btnDelete.setEnabled(bEditable);
    }
    
    void clear() {
       
    	jTableEmployee.removeAll();
        
    }
     
    
    private void tableSelectionValueChanged(javax.swing.event.ListSelectionEvent evt) {
       
  
    }
    
   
    private void initComponents() {
    	
        java.awt.GridBagConstraints gridBagConstraints;

        jScrollPaneEmployeePool = new javax.swing.JScrollPane();
        myTableModel = new MyTableModelEmployee(
				new String[]{"Name","Role","Start Date","Due Date","Progress"},
				new Object[30][5]);
        jTableEmployee = new javax.swing.JTable(myTableModel);
        myTableModel.initTable(jTableEmployee);
        jTableEmployee.setAutoCreateRowSorter(Boolean.TRUE);
        jTableEmployee.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        ListSelectionModel tblSM = jTableEmployee.getSelectionModel();
        tblSM.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                tableSelectionValueChanged(evt);
            }
        });

        jPanelTasks = new javax.swing.JPanel();  
        btnAddNew = new javax.swing.JButton();
        btnModify = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();

        setLayout(new java.awt.GridBagLayout());

        jPanelTasks.setLayout(new java.awt.GridBagLayout());
        jPanelTasks.setBorder(new javax.swing.border.TitledBorder("Employees"));
        
        jTableEmployee.setShowHorizontalLines(false);
        jScrollPaneEmployeePool.setViewportView(jTableEmployee);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        jPanelTasks.add(jScrollPaneEmployeePool, gridBagConstraints);

       
        btnAddNew.setText("Add New");
        btnAddNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	btnAddNewTaskActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        jPanelTasks.add(btnAddNew,gridBagConstraints);

        btnModify.setText("Modify");
        btnModify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	btnModifyTaskActionPerformed(evt);
            }
        });

    
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        jPanelTasks.add(btnModify,gridBagConstraints);

        btnDelete.setText("Delete");
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	btnDeleteTaskActionPerformed(evt);
            }
        });
        
       

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 1.0;
        jPanelTasks.add(btnDelete,gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1;
        gridBagConstraints.weighty = 1;
        add(jPanelTasks,gridBagConstraints);
        
      
    }
    
  
    private void btnModifyTaskActionPerformed(java.awt.event.ActionEvent evt) {
        
    }
    
    private void btnAddNewTaskActionPerformed(java.awt.event.ActionEvent evt) {
    
    	EmployeeDialog dlg = new EmployeeDialog(this,true,1);
		dlg.setVisible(true);
    }
    
    private void btnDeleteTaskActionPerformed(java.awt.event.ActionEvent evt) {
      
    }
     
    private javax.swing.JButton btnAddNew;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnModify;
    private javax.swing.JPanel jPanelTasks;
    private javax.swing.JScrollPane jScrollPaneEmployeePool;
    private javax.swing.JTable jTableEmployee;
    private MyTableModelEmployee myTableModel;
   
}
